﻿//using System;
//using System.Collections.Generic;
//using System.Text;
//using System.Net;
//using System.Net.Sockets;



//namespace TakeNote
//{
//    class Server_Agent
//    {

//       static void Main(string[] args)
//        {
//            int recv;
//            byte[] data = new byte[1024];
//            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 9050);
//            //udp 소켓 생성
//            Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
//            newsock.Bind(ipep);
//            Console.WriteLine("Waition for a client...");

//            //Endpoint를 생성한다.
//            IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
//            EndPoint remote = (EndPoint)sender;

//            //receive나 send를 할때 endpoint를 사용한다. receive는 ref를 사용
//            recv = newsock.ReceiveFrom(data, ref remote);

//            Console.WriteLine("Message received from {0} : ", remote.ToString());
//            Console.WriteLine(Encoding.UTF8.GetString(data, 0, recv));

//            string welcome = "Welcome to my test Server";
//            data = Encoding.UTF8.GetBytes(welcome);

//            newsock.SendTo(data, data.Length, SocketFlags.None, remote);

//            while (true)
//            {
//                data = new byte[1024];
//                recv = newsock.ReceiveFrom(data, ref remote);

//                Console.WriteLine(Encoding.UTF8.GetString(data, 0, recv));
//                newsock.SendTo(data, recv, SocketFlags.None, remote);
//            }
//       }
//  }
//}